package com.undefind;

import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        while (true){
            Scanner sc = new Scanner(System.in);
            NGuessNumber game = new NGuessNumber();
            game.generateAnswer();
            System.out.println(game.answer[0]);
            System.out.println(game.answer[1]);
            System.out.println(game.answer[2]);
            System.out.println(game.answer[3]);
            while (true){
                int[] inputresult = game.getPlayerInput();
                Map<Integer,Boolean> compResult = game.compareGuessAnswer(game.answer,inputresult);
                if (game.isWin(compResult)){
                    System.out.println("你胜利了");
                    break;
                }else{
                    for(int i = 0;i<compResult.size();i++){
                        System.out.println("数字 ["+(i+1)+"]"+( (boolean)(compResult.values().toArray()[i])?"正确":"错误"));
                    }
                }
            }
            System.out.println("要再来一局吗? 按1继续");
            if (sc.nextInt() != 1){
                break;
            }
        }
    }
}
